package com.itfreer.xjmh.cycle;


import com.itfreer.xjmh.cycle.dao.CycleAirSecurityShowDao;
import com.itfreer.xjmh.temporary.TemporaryShowService;
import com.itfreer.xjmh.temporary.dao.TemporaryShowDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class CycleAirSecurityShowServiceImpl implements CycleAirSecurityShowService {

    @Autowired(required = false)
    private CycleAirSecurityShowDao showDao;



    @Override
    public List<Map<String, Object>> getShowData(Map<String, Object> where) {
        String startTime = null;
        String airport = null;
        String adminId = null;
        String endTime = null;
        if (where.get("startTime") != null && !"".equals(where.get("startTime"))) {
            startTime = (String) where.get("startTime");
        }
        if (where.get("endTime") != null && !"".equals(where.get("endTime"))) {
            endTime = (String) where.get("endTime");
        }
        if (where.get("airport") != null && !"".equals(where.get("airport"))) {
            airport = (String) where.get("airport");
        }

        if (where.get("adminId") != null && !"".equals(where.get("adminId"))) {
            adminId = (String) where.get("adminId");
        }



        List<Map<String, Object>> list = showDao.getShowData(startTime, endTime, airport, adminId);
        list.forEach(item->{
            item.forEach((key, value) ->{
                if (value != null) {
                    if (!"airportName".equals(key) && !"airport".equals(key)){
                        item.put(key, new String((byte[])value));
                    }

                }
            });
        });
        System.out.println(list.toString());
        return list;
    }

    @Override
    public List<Map<String, Object>> getShowDate() {
        List<Map<String, Object>> list = showDao.getShowDate();
/*        list.forEach(item->{
            item.forEach((key, value) ->{
                if (value != null) {
                    if (!"date".equals(key)){
                        item.put(key, new String((byte[])value));
                    }

                }
            });
        });*/
        return list;
    }

}
